package com.ycsyxt.controller;

import java.util.Objects;

import com.github.pagehelper.PageHelper;
import com.ycsyxt.page.PageParam;
import com.ycsyxt.page.TableSupport;
import com.ycsyxt.util.SqlUtil;

/**
 * @author ycs(15241496739 @ 163.com)
 * @date 2021/12/25
 **/
public class BaseController {
    /**
     * 设置请求分页数据
     */
    protected void startPage() {
        PageParam pageParam = TableSupport.buildPageRequest();
        Integer pageNum = pageParam.getPageNum();
        Integer pageSize = pageParam.getPageSize();
        if (Objects.nonNull(pageNum) && Objects.nonNull(pageSize)) {
            String orderBy = SqlUtil.escapeOrderBySql(pageParam.getOrderBy());
            Boolean reasonable = pageParam.getReasonable();
            PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
        }
    }
}
